# 导入Path类，用于处理文件路径
from pathlib import Path

# 定义项目的基础目录
BASE_DIR = Path(__file__).resolve().parent.parent

# 定义Django项目的密钥
SECRET_KEY = 'django-insecure-secret-key'

# 开启调试模式
DEBUG = True

# 定义允许访问的主机列表
ALLOWED_HOSTS = []

# 定义已安装的应用列表
INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'django_celery_beat',
    'hosts',
]

# 定义中间件列表
MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
    'hosts.middleware.RequestTimerMiddleware',
]

# 定义项目的URL配置文件
ROOT_URLCONF = 'host_manager.urls'

# 定义模板配置
TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

# 定义WSGI应用路径
WSGI_APPLICATION = 'host_manager.wsgi.application'

# 定义数据库配置
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.mysql',
        'NAME': 'cs',
        'HOST': "localhost",
        'PORT': 3306,
        "USER": "root",
        "PASSWORD": "root"
    }
}

# 定义密码验证器列表
AUTH_PASSWORD_VALIDATORS = []

# 定义项目的默认语言
LANGUAGE_CODE = 'en-us'

# 定义项目的时区
TIME_ZONE = 'Asia/Shanghai'

# 开启国际化支持
USE_I18N = True

# 开启时区支持
USE_TZ = True

# 定义静态文件的URL
STATIC_URL = '/static/'

# 定义默认的自动字段类型
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

# 定义Celery的Broker URL
CELERY_BROKER_URL = 'redis://localhost:6379/0'
# 定义Celery的结果后端
CELERY_RESULT_BACKEND = 'redis://localhost:6379/0'
# 定义Celery的时区
CELERY_TIMEZONE = 'Asia/Shanghai'
